package cn.simon.service;


import cn.simon.mapper.AddressMapper;
import cn.simon.model.Address;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressService {
    @Autowired
    private AddressMapper addressMapper;

    /**
     *显示所有地址
     */
    public List<Address> findAll(){
        Wrapper<Address> addressWrapper = new QueryWrapper<Address>().lambda().select(Address::getAddressId,Address::getAddressName,
                Address::getAddressPhone,Address::getAddressProvince,Address::getAddressCity,Address::getAddressDistrict,Address::getAddressDetail);
        return addressMapper.selectList(addressWrapper);
    }

    public int add(Address address){
        return addressMapper.insert(address);
    }

    public List<Address> findById(Integer id){
        return addressMapper.findById(id);
    }

}
